package com.zhuge_new.Adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zhuge_new.R;
import com.zhuge_new.bean.DirectBean;
import com.zhuge_new.bean.IndirectBean;
import com.zhuge_new.share.BaseHttp;
import com.zhuge_new.untils.RemoveDuplicateUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/10/16.
 */

public class IndiectSonAdapter extends BaseQuickAdapter<IndirectBean.LsBean, BaseViewHolder> {


    private Context context;
    private List<IndirectBean.LsBean> data = new ArrayList<>();
    private String month;
    private ArrayList<String> listmoney = new ArrayList<>();
    private ArrayList list_subscript=new ArrayList();
    public IndiectSonAdapter(Context context, @Nullable List<IndirectBean.LsBean> data, String month, ArrayList list_subscript) {
        super(R.layout.item_direct_part, data);
        this.context = context;
        this.data = data;
        this.month = month;
        this.list_subscript=list_subscript;
    }


    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        RequestOptions options = new RequestOptions()
                .centerCrop()
                .placeholder(R.mipmap.ic_launcher)
                .placeholder(R.mipmap.ic_launcher)
                .priority(Priority.HIGH);
        RemoveDuplicateUtil.removeDuplicate(list_subscript);
        int subscript= (int) list_subscript.get(position);
        Log.e(String.valueOf(list_subscript.size()),"打印数量");
        holder.setText(R.id.direct_identity, "[" + data.get(subscript).getLevelName() + "]");
        holder.setText(R.id.direct_name, data.get(subscript).getNickName());
        holder.setText(R.id.direct_time, data.get(subscript).getCreateDate().substring(5, data.get(subscript).getCreateDate().length() - 3));
        if (data.get(subscript).getProfitSum().isEmpty()) {
            holder.setText(R.id.direct_money, "+0.00");
        } else {
            holder.setText(R.id.direct_money, "+" + data.get(subscript).getProfitSum());
        }
        ImageView direct_head = holder.getView(R.id.direct_head);
        Glide.with(context).load(BaseHttp.baseImg).apply(options).into(direct_head);
    }

    @Override
    protected void convert(BaseViewHolder helper, IndirectBean.LsBean item) {

    }

    @Override
    public int getItemCount() {
        for (int i = 0; i < data.size(); i++) {
            if (data.get(i).getCreateDate().substring(5,7).equals(month)){
                listmoney.add(data.get(i).getCreateDate());
            }
        }
        int num=listmoney.size();
        listmoney.clear();
        return num;
    }




}
